<!doctype html>
<!--
MD5calc in HTML and Javascript
version alpha 5

Written by @chenxiaoqino @HJin_me @goldengrape, 2011-12-27
Based on js MD5 Lib
Published under New BSD license: http://www.opensource.org/licenses/bsd-license.php
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*   Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>md5 password creator</title>
<style>
body {line-height:150%;}
div {padding:10px;}
span {background:rgb(255,255,190);}
div#resultbox span {font-family:monospace;}
#recreatebox {display:none;}
</style>
<script>
/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 
 Modified and compressed by @chenxiaoqino
 */
function md5(a){function b(a){return d(c(e(a)))}function c(a){return g(h(f(a),a.length*8))}function d(a){var b="0123456789abcdef",c="",d;for(var e=0;e<a.length;e++)d=a.charCodeAt(e),c+=b.charAt(d>>>4&15)+b.charAt(d&15);return c}function e(a){var b="",c=-1,d,e;while(++c<a.length)d=a.charCodeAt(c),e=c+1<a.length?a.charCodeAt(c+1):0,55296<=d&&d<=56319&&56320<=e&&e<=57343&&(d=65536+((d&1023)<<10)+(e&1023),c++),d<=127?b+=String.fromCharCode(d):d<=2047?b+=String.fromCharCode(192|d>>>6&31,128|d&63):d<=65535?b+=String.fromCharCode(224|d>>>12&15,128|d>>>6&63,128|d&63):d<=2097151&&(b+=String.fromCharCode(240|d>>>18&7,128|d>>>12&63,128|d>>>6&63,128|d&63));return b}function f(a){var b=Array(a.length>>2);for(var c=0;c<b.length;c++)b[c]=0;for(var c=0;c<a.length*8;c+=8)b[c>>5]|=(a.charCodeAt(c/8)&255)<<c%32;return b}function g(a){var b="";for(var c=0;c<a.length*32;c+=8)b+=String.fromCharCode(a[c>>5]>>>c%32&255);return b}function h(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>9<<4)+14]=b;var c=1732584193,d=-271733879,e=-1732584194,f=271733878;for(var g=0;g<a.length;g+=16){var h=c,i=d,o=e,p=f;c=j(c,d,e,f,a[g+0],7,-680876936),f=j(f,c,d,e,a[g+1],12,-389564586),e=j(e,f,c,d,a[g+2],17,606105819),d=j(d,e,f,c,a[g+3],22,-1044525330),c=j(c,d,e,f,a[g+4],7,-176418897),f=j(f,c,d,e,a[g+5],12,1200080426),e=j(e,f,c,d,a[g+6],17,-1473231341),d=j(d,e,f,c,a[g+7],22,-45705983),c=j(c,d,e,f,a[g+8],7,1770035416),f=j(f,c,d,e,a[g+9],12,-1958414417),e=j(e,f,c,d,a[g+10],17,-42063),d=j(d,e,f,c,a[g+11],22,-1990404162),c=j(c,d,e,f,a[g+12],7,1804603682),f=j(f,c,d,e,a[g+13],12,-40341101),e=j(e,f,c,d,a[g+14],17,-1502002290),d=j(d,e,f,c,a[g+15],22,1236535329),c=k(c,d,e,f,a[g+1],5,-165796510),f=k(f,c,d,e,a[g+6],9,-1069501632),e=k(e,f,c,d,a[g+11],14,643717713),d=k(d,e,f,c,a[g+0],20,-373897302),c=k(c,d,e,f,a[g+5],5,-701558691),f=k(f,c,d,e,a[g+10],9,38016083),e=k(e,f,c,d,a[g+15],14,-660478335),d=k(d,e,f,c,a[g+4],20,-405537848),c=k(c,d,e,f,a[g+9],5,568446438),f=k(f,c,d,e,a[g+14],9,-1019803690),e=k(e,f,c,d,a[g+3],14,-187363961),d=k(d,e,f,c,a[g+8],20,1163531501),c=k(c,d,e,f,a[g+13],5,-1444681467),f=k(f,c,d,e,a[g+2],9,-51403784),e=k(e,f,c,d,a[g+7],14,1735328473),d=k(d,e,f,c,a[g+12],20,-1926607734),c=l(c,d,e,f,a[g+5],4,-378558),f=l(f,c,d,e,a[g+8],11,-2022574463),e=l(e,f,c,d,a[g+11],16,1839030562),d=l(d,e,f,c,a[g+14],23,-35309556),c=l(c,d,e,f,a[g+1],4,-1530992060),f=l(f,c,d,e,a[g+4],11,1272893353),e=l(e,f,c,d,a[g+7],16,-155497632),d=l(d,e,f,c,a[g+10],23,-1094730640),c=l(c,d,e,f,a[g+13],4,681279174),f=l(f,c,d,e,a[g+0],11,-358537222),e=l(e,f,c,d,a[g+3],16,-722521979),d=l(d,e,f,c,a[g+6],23,76029189),c=l(c,d,e,f,a[g+9],4,-640364487),f=l(f,c,d,e,a[g+12],11,-421815835),e=l(e,f,c,d,a[g+15],16,530742520),d=l(d,e,f,c,a[g+2],23,-995338651),c=m(c,d,e,f,a[g+0],6,-198630844),f=m(f,c,d,e,a[g+7],10,1126891415),e=m(e,f,c,d,a[g+14],15,-1416354905),d=m(d,e,f,c,a[g+5],21,-57434055),c=m(c,d,e,f,a[g+12],6,1700485571),f=m(f,c,d,e,a[g+3],10,-1894986606),e=m(e,f,c,d,a[g+10],15,-1051523),d=m(d,e,f,c,a[g+1],21,-2054922799),c=m(c,d,e,f,a[g+8],6,1873313359),f=m(f,c,d,e,a[g+15],10,-30611744),e=m(e,f,c,d,a[g+6],15,-1560198380),d=m(d,e,f,c,a[g+13],21,1309151649),c=m(c,d,e,f,a[g+4],6,-145523070),f=m(f,c,d,e,a[g+11],10,-1120210379),e=m(e,f,c,d,a[g+2],15,718787259),d=m(d,e,f,c,a[g+9],21,-343485551),c=n(c,h),d=n(d,i),e=n(e,o),f=n(f,p)}return Array(c,d,e,f)}function i(a,b,c,d,e,f){return n(o(n(n(b,a),n(d,f)),e),c)}function j(a,b,c,d,e,f,g){return i(b&c|~b&d,a,b,e,f,g)}function k(a,b,c,d,e,f,g){return i(b&d|c&~d,a,b,e,f,g)}function l(a,b,c,d,e,f,g){return i(b^c^d,a,b,e,f,g)}function m(a,b,c,d,e,f,g){return i(c^(b|~d),a,b,e,f,g)}function n(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function o(a,b){return a<<b|a>>>32-b}return b(a);var p}
/*
a simple Hex string to Decimal Big Integer String function
Written by @chenxiaoqino
Published under New BSD license
*/
function hex2dec(a){var b=new Array,c,d="";a=d+a,l=a.length;var e=Math.ceil(l*1.21);for(i=0;i<e;i++)b[i]=0;for(i=0;i<l;i++){c=a.charCodeAt(i),c-=48,c>32&&(c-=32),c>9&&(c-=7);for(j=0;j<e;j++)b[j]*=16;b[0]+=c;for(j=0;j<e;j++)while(b[j]>=10)b[j]-=10,b[j+1]+=1}while(b[--e]==0);while(e>=0)d+=String.fromCharCode(b[e--]+48);return d==""&&(d="0"),d}
/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/javascript-base64.html
*
**/
var Base64 = {
 
	// private property
 	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	// _keyStr  : "乾坤屯蒙需讼师比畜履泰否同大谦豫随蛊临观噬贲剥复妄颐过坎离咸恒遁壮晋夷家睽蹇解损益夬姤萃升困井革鼎雷艮渐归丰旅巽泽涣节孚小既未", 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
function b64encode(input)
{
return Base64.encode(input);
}
function b64decode(input)
{
return Base64.decode(input);
}

</script>
<script>
function $(id) {return document.getElementById(id);}
function createPwd()
{
	var salt="";//add your own 
	/*
	input web name by radio or text
	*/
	for(var i = 0; i < document.form.web.length; i++) {
		if(document.form.web[i].checked && document.form.web[i].value != "none") {
			$("srcbox2").value = document.form.web[i].value;
		}
	}
	var rawString = ($("srcbox1").value || '') 
			+ (salt)
			+ ($("srcbox2").value || '')
			+ ($("version").value || '');
			// restore to main stream, subpwd=md5(rawString)
			// also can use md5(salt), which will extend the lenght of rawString
	var str_md5 = md5(rawString);
	var str_decimal = hex2dec(str_md5);
	var str_base64=b64encode(str_md5);
	var length = parseInt($("cutselect").value) || str_decimal.length;
	
	var boxhex=$("hexresult");
	boxhex.innerHTML=str_md5.substr(0,length);
	var boxdec=$("decresult");
	boxdec.innerHTML=str_decimal.substr(0,6);
	var boxbase64=$("base64result");
	boxbase64.innerHTML=str_base64.substr(0,length);
	return false;
}
</script>
</head>
<body>
	<form action="#" onsubmit="return createPwd();" name="form">
			输入主密码:
			<input type="password" id="srcbox1"/>
			<br>

			输入网站名<input type="radio" id="none" name="web" value="none" checked ><label for="none"></label><input type="text" id="srcbox2"/>
			<br>
			或者从下面的列表中选取：<br>
 
			<br>邮件：
				<input type="radio" id="gmail" name="web" value="gmail"><label for="gmail">gmail</label>
				<input type="radio" id="msn" name="web" value="msn"><label for="msn">msn</label>
				<input type="radio" id="yahoo" name="web" value="yahoo"><label for="yahoo">yahoo</label>
				<input type="radio" id="sina" name="web" value="sina"><label for="sina">sina</label>
				<input type="radio" id="sohu" name="web" value="sohu"><label for="sohu">sohu</label>
				<input type="radio" id="163" name="web" value="163"><label for="163">163</label>
				<input type="radio" id="qq" name="web" value="qq"><label for="qq">qq</label>
				<input type="radio" id="263" name="web" value="263"><label for="263">263</label>
			<br>社交：
				<input type="radio" id="twitter" name="web" value="twitter"><label for="twitter">twitter</label>
				<input type="radio" id="facebook" name="web" value="facebook"><label for="facebook">facebook</label>
				<input type="radio" id="baidu" name="web" value="baidu"><label for="baidu">百度</label>
				<input type="radio" id="renren" name="web" value="renren"><label for="renren">人人</label>
				<input type="radio" id="kaixin" name="web" value="kaixin"><label for="kaixin">开心</label>
				<input type="radio" id="tianya" name="web" value="tianya"><label for="tianya">天涯</label>
				<input type="radio" id="mop" name="web" value="mop"><label for="mop">猫扑</label>
				<input type="radio" id="qq" name="web" value="qq"><label for="qq">qq</label>
			<br>购物：
				<input type="radio" id="taobao" name="web" value="taobao"><label for="taobao">淘宝</label>
				<input type="radio" id="alipay" name="web" value="alipay"><label for="alipay">支付宝</label>
				<input type="radio" id="360buy" name="web" value="360buy"><label for="360buy">京东</label>
				<input type="radio" id="newegg" name="web" value="newegg"><label for="newegg">新蛋</label>
				<input type="radio" id="dangdang" name="web" value="dangdang"><label for="dangdang">当当</label>
				<input type="radio" id="amazon" name="web" value="amazon"><label for="amazon">卓越</label>
				<input type="radio" id="vancl" name="web" value="vancl"><label for="vancl">凡客</label>
			<br>银行：
				<input type="radio" id="icbc" name="web" value="icbc"><label for="icbc">工商银行</label>
				<input type="radio" id="ccb" name="web" value="ccb"><label for="ccb">建设银行</label>
				<input type="radio" id="abchina" name="web" value="abchina"><label for="abchina">农业银行</label>
				<input type="radio" id="cmbchina" name="web" value="cmbchina"><label for="cmbchina">招商银行</label>
				<input type="radio" id="boc" name="web" value="boc"><label for="boc">中国银行</label>
				<input type="radio" id="bankcomm" name="web" value="bankcomm"><label for="bankcomm">交通银行</label>
			<br>手机：
				<input type="radio" id="10086" name="web" value="10086"><label for="10086">移动</label>
				<input type="radio" id="10010" name="web" value="10010"><label for="10010">联通</label>
				<input type="radio" id="ct10000" name="web" value="ct10000"><label for="ct10000">电信</label>
				<input type="radio" id="10010" name="web" value="10010"><label for="10010">网通</label>
			<br>
			<br>
			密码版本   :
			<select id="version" >
				<option value="2012spring">2012春</option>
				<option value="2012summer">2012夏</option>
				<option value="2012autum">2012秋</option>
				<option value="2012winter">2012冬</option>
			</select>
			<br>
			密码长度   :
			<select id="cutselect" onchange="cut();" >   
				<option value="20" selected >20位</option>
				<option value="32">32位</option>
	    			<option value="16" >16位</option>
	    			<option value="12" >12位</option>
	    			<option value="10" >10位</option>
	    			<option value="8" >8位</option>
				<option value="6" >6位</option>
			</select>
			<br>
	    		<input type="submit" id="submit" value="计算密码"/>
	
	</form>
	字符密码：
	<textarea id="hexresult" onFocus=this.select() onMouseOver=this.focus() rows="1" ></textarea>
	复杂字符密码：
	<textarea id="base64result" onFocus=this.select() onMouseOver=this.focus() rows="1" ></textarea>
	数字密码：
	<textarea id="decresult" onFocus=this.select() onMouseOver=this.focus() rows="1" ></textarea>
	<br>


</body>
</html>

